home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / science / sm32a.zip / LIBRARY / DATAPLOT.LI4 < prev    next >
Text File  |  1994-07-20  |  1KB  |  44 lines

  1. #  library dataplot.li
  2. #  dataplot() 
  3. #  plots data ( [x1,x2,...], [y1,y2,...] ) on xy-plane
  4. #  dataplot( [x1,x2,...], [y1,y2,...], 1) plots a pair of data with 
  5. #  linked dots
  6. #  dataplot( [x1,x2,...], [y1,y2,...], 0) plots a pair of data as dots
  7. #  by default, link=0.
  8. #  e.g.    dataplot([1,2,3], [1,4,9])
  9.  
  10. dataplot(x_, y_, link_) := block(numeric:=on,
  11.     graph,
  12.     xmax:=max(x)*1.1,
  13.     xmin:=min(x)*0.9,
  14.     ymax:=max(y)*1.1,
  15.     ymin:=min(y)*0.9,
  16.     getmaxy3:=getmaxy-30,
  17.     getmaxy2:=getmaxy3+1,
  18.     dx:=(xmax-xmin)/(getmaxx-40),
  19.     dy:=(ymax-ymin)/(getmaxy-30),
  20.     length:=length(y),
  21.     line(40,getmaxy3,getmaxx,getmaxy3),
  22.     line(40,0,40,getmaxy3),
  23.     moveto(0,0),
  24.     writes(ymax),
  25.     moveto(0,getmaxy3),
  26.     writes(ymin),
  27.     moveto(35,getmaxy-20),
  28.     writes(xmin),
  29.     moveto(getmaxx-30,getmaxy-20),
  30.     writes(xmax),
  31.     setviewport(40,0,getmaxx,getmaxy3,1),
  32.     moveto(0,getmaxy3),
  33.     do( circle((member(x,j)-xmin)/dx,getmaxy2-(member(y,j)-ymin)/dy,2),
  34.     j,1,length,1),
  35.     setcolor(colorno(yellow)),
  36.     moveto((member(x,1)-xmin)/dx,getmaxy2-(member(y,1)-ymin)/dy),
  37.     if(link,do( lineto((member(x,j)-xmin)/dx,getmaxy2-(member(y,j)-ymin)/dy),
  38.     j,1,length,1)),
  39.     numeric:=off,
  40.     readchar,
  41.     text,
  42.     local(dx,dy,length))
  43. dataplot(x_,y_) := dataplot(x,y,0)    
  44.